// pages/bind/bind.js
import {bind} from "../../server/bind"
import Toast from '../../miniprogram_npm/@vant/weapp/toast/toast';
import {back,getUserInfo} from "../../utils/login"

Page({

  /**
   * 页面的初始数据
   */
  data: {

  },
  bind(){
    let data = {
      type:"bind",
      openid:wx.getStorageSync('openid')
    }
    bind(data).then(res => {
      // console.log(res);
      Toast({
        message: '绑定成功',
        type: 'success',
        onClose: () => {    
          getUserInfo().then(res => {
            back() 
          })              
        }
      });
    })
  },
  unbind(){
    back() 
  }
})